package service;

import dao.ImplementUser;
import pojo.User;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.sql.SQLException;

/**
 * 添加用户
 */
@WebServlet("/addAreaUserServlet")
public class addAreaUserServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String usename=req.getParameter("usename");
        ImplementUser implementUser=new ImplementUser();
        User user=new User();
        try {
            user=implementUser.getuser(usename);
            implementUser.updatepower(user);
            resp.sendRedirect(req.getContextPath()+"/areaUsers.jsp");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}
